<template>
    <div style="width:100%; display:flex;">
        <div style="flex:1">
            <a-select v-model="form.dept_id" :options="list" placeholder="请选择合同公司" allow-clear allow-search :filter-option="filterOption" :field-names="{ value: 'id', label: 'name' }" a />
        </div>
        <a-button type="primary" style="margin-left:10px;" @click="openAdd">新增客户</a-button>
    </div>


    <!-- 新增/编辑 -->
    <a-modal :mask-closable="false"  v-model:visible="visible_Add" :width="1080" @cancel="visible_Add=false" :on-before-ok="handleAddOk">
        <template #title>
          新增
        </template>
        <div class="contenBox" style="overflow: auto;">
          <div style="margin-bottom: 16px">
            <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
              <template #title>
                <div style="color:rgba(0, 82, 217, 1);font-weight:600">基本信息</div>
              </template>
              <div class="flex marbot24 align_center" style="width:100%" >
                <div class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 ">类型：</div>
                  <div class="flex align_center" style="height:32px">
                    <a-space size="large">
                      <a-radio-group v-model="addItem.type" :options="typeList" @change="handleType" />
                    </a-space>
                  </div>
                </div>
                <div  class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div  class="font14 ">客户类型：</div>
                  <div class="flex align_center" style="height:32px">
                    <a-space size="large">
                      <a-radio-group v-model="addItem.customer_type" :options="customerTypeList" />
                    </a-space>
                  </div>
                </div>
                <div class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 ">状态：</div>
                  <div class="flex align_center" style="height:32px">
                    <a-space size="large">
                      <a-radio-group v-model="addItem.status" :options="statusList" />
                    </a-space>
                  </div>
                </div>
              </div>
              <div class="flex marbot24 align_center" style="width:100%" v-if="addItem.customer_type == 1">
                <div  style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4 flex align_center"><div style="color: red;">*</div>客户名称：</div>
                  <a-select style="flex:1" :loading="loading" placeholder="请选择客户名称" v-model="addItem.name"
                            @search="handleSearch" :filter-option="false" @change='handleYinhanInfo($event)'  allow-search >
                    <a-option v-for="item of deptSearchList" :value="item.creditNo" >{{item.companyName}}</a-option>
                  </a-select>
                  <!-- <a-input v-model="addItem.name" placeholder="请输入客户名称" allow-clear @change="handleKehuInfo" /> -->
                </div>
                <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                  <div class="font14 marbot4">负责人:</div>
                  <a-input v-model="addItem.leader" placeholder="请输入负责人" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4 flex align_center"><div style="color: red;">*</div>联系电话:</div>
                  <a-input v-model="addItem.phone" placeholder="请输入联系电话" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">邮箱:</div>
                  <a-input v-model="addItem.e_mail" placeholder="请输入邮箱" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                  <div class="font14 marbot4">纳税人识别号:</div>
                  <a-input v-model="addItem.card_id" placeholder="请输入纳税人识别号" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">标签组:</div>
                  <a-select v-model="addItem.tag_ids"  placeholder="请选择标签" multiple>
                    <a-option v-for="item of tagList" :value="item.id" :label="item.name" />
                  </a-select>
                </div>
              </div>
              <div class="flex marbot24 align_center" style="width:100%" v-if="addItem.customer_type == 2">
                <div  style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">客户名称：</div>
                  <a-input v-model="addItem.name" placeholder="请输入客户名称" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                  <div class="font14 marbot4">联系电话:</div>
                  <a-input v-model="addItem.phone" placeholder="请输入负责人" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">邮箱:</div>
                  <a-input v-model="addItem.e_mail" placeholder="请输入邮箱" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 2">
                <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                  <div class="font14 marbot4">身份证号:</div>
                  <a-input v-model="addItem.card_id" placeholder="请输入身份证号" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">标签组:</div>
                  <a-select v-model="addItem.tag_ids"  placeholder="请选择标签" multiple>
                    <a-option v-for="item of tagList" :value="item.id" :label="item.name" />
                  </a-select>
                </div>
              </div>
              <div class="flex marbot24" style="width:100%">
                <div style="width:100%;">
                  <div class="font14 marbot4">营业执照：</div>
                  <ma-upload v-model="addItem.file" type='image' />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%">
                <div style="width:100%;">
                  <div class="font14 marbot4">备注:</div>
                  <a-textarea placeholder="请输入备注" v-model="addItem.remark" allow-clear/>
                </div>
              </div>
            </a-card>
          </div>
          <div style="margin-bottom: 16px">
            <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
              <template #title>
                <div style="color:rgba(0, 82, 217, 1);font-weight:600">工商信息</div>
              </template>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">公司名称：</div>
                  <a-input v-model="addItem.company_data.companyName" placeholder="请输入公司名称" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">公司类型：</div>
                  <a-input v-model="addItem.company_data.companyType" placeholder="请输入公司类型" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">法定代表人：</div>
                  <a-input v-model="addItem.company_data.legalPerson" placeholder="请输入法定代表人" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">法人类型：</div>
                  <a-input v-model="addItem.company_data.legalPersonType" placeholder="请输入法人类型" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">电话号码：</div>
                  <a-input v-model="addItem.company_data.phoneNumber" placeholder="请输入电话号码" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">电话备注：</div>
                  <a-input v-model="addItem.company_data.phoneNumber_note" placeholder="请输入电话备注" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">注册资本：</div>
                  <a-input v-model="addItem.company_data.capital" placeholder="请输入注册资本" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">实收注册资金：</div>
                  <a-input v-model="addItem.company_data.realCapital" placeholder="请输入实收注册资金" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">注册码：</div>
                  <a-input v-model="addItem.company_data.companyCode" placeholder="请输入注册码" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">企业信用代码：</div>
                  <a-input v-model="addItem.company_data.creditNo" placeholder="请输入企业信用代码" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">组织机构代码：</div>
                  <a-input v-model="addItem.company_data.orgCode" placeholder="请输入组织机构代码" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">经营范围：</div>
                  <a-input v-model="addItem.company_data.businessScope" placeholder="请输入经营范围" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">登记机关：</div>
                  <a-input v-model="addItem.company_data.authority" placeholder="请输入登记机关" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">经营状态：</div>
                  <a-input v-model="addItem.company_data.companyStatus" placeholder="请输入经营状态" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">成立时间：</div>
                  <a-input v-model="addItem.company_data.establishDate" placeholder="请输入成立时间" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">营业开始时间：</div>
                  <a-input v-model="addItem.company_data.operationStartdate" placeholder="请输入营业开始时间" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">营业结束时间：</div>
                  <a-input v-model="addItem.company_data.operationEnddate" placeholder="请输入营业结束时间" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">核准日期：</div>
                  <a-input v-model="addItem.company_data.issueDate" placeholder="请输入核准日期" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">省份：</div>
                  <a-input v-model="addItem.company_data.province" placeholder="请输入省份" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">省份行政区号：</div>
                  <a-input v-model="addItem.company_data.provinceCode" placeholder="请输入省份行政区号" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">地市：</div>
                  <a-input v-model="addItem.company_data.city" placeholder="请输入地市" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">地市行政区号：</div>
                  <a-input v-model="addItem.company_data.cityCode" placeholder="请输入地市行政区号" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">地区：</div>
                  <a-input v-model="addItem.company_data.district" placeholder="请输入地区" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">地区行政区号：</div>
                  <a-input v-model="addItem.company_data.districtCode" placeholder="请输入地区行政区号" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">注册地址：</div>
                  <a-input v-model="addItem.company_data.companyAddress" placeholder="请输入注册地址" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">行业：</div>
                  <a-input v-model="addItem.company_data.industry" placeholder="请输入行业" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">曾用名：</div>
                  <a-input v-model="addItem.company_data.historyNames" placeholder="请输入曾用名" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">更新时间：</div>
                  <a-input v-model="addItem.company_data.lastUpdatedTime" placeholder="请输入更新时间" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">登记状态：</div>
                  <a-input v-model="addItem.company_data.companyStatus" placeholder="请输入登记状态" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">邮箱：</div>
                  <a-input v-model="addItem.company_data.email" placeholder="请输入邮箱" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">邮箱备注：</div>
                  <a-input v-model="addItem.company_data.email_note" placeholder="请输入邮箱备注" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">地址：</div>
                  <a-input v-model="addItem.company_data.address" placeholder="请输入地址" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">地址备注：</div>
                  <a-input v-model="addItem.company_data.address_note" placeholder="请输入地址备注" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">网址：</div>
                  <a-input v-model="addItem.company_data.website" placeholder="请输入网址" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">网址备注：</div>
                  <a-input v-model="addItem.company_data.website_note" placeholder="请输入网址备注" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 2">
                <div class="flex align_center" style="flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">抬头名称：</div>
                  <a-input v-model="addItem.companyName" placeholder="请输入抬头名称" allow-clear  />
                </div>
              </div>
            </a-card>
          </div>
          <div >
            <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
              <template #title>
                <div style="color:rgba(0, 82, 217, 1);font-weight:600">银行账户信息</div>
              </template>
              <div class="flex marbot24" style="width:100%">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">开户银行：</div>
                  <a-input v-model="addItem.opening_bank" placeholder="请输入开户银行" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">银行账号：</div>
                  <a-input v-model="addItem.account" placeholder="请输入银行账号" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">账户名称：</div>
                  <a-input v-model="addItem.account_name" placeholder="请输入账户名称" allow-clear  />
                </div>
                <div style="flex:1;">
                  
                </div>
              </div>
            </a-card>
          </div>
        </div>
      </a-modal>

</template>

<script setup>
import { inject, onMounted, ref } from 'vue'
import { request } from "@/utils/request.js";
import dept from "@/api/system/dept";
import { pinyin } from "pinyin-pro"
import { Message,Modal } from '@arco-design/web-vue'
// 表单数据
const form = inject('formModel')
// 字典数据集合
const dict = inject('dictList')
const loading = ref(false)
const deptSearchList = ref([])
// 组件props
const props = defineProps({
  component: Object,    // 组件配置信息
  customField: { type: String, default: undefined }, // 自定义字段名称，用于子表单
})
const filterOption = (v,option)=>{
    return option.keywords.some(keywords=>keywords.includes(v))
}

const addItem = ref({
    type:1,
    customer_type:1,
    status:1,
    name:'',
    leader:'',
    phone:'',
    e_mail:'',
    card_id:'',
    file:'',
    tag_ids:[],
    remark:'',
    // 工商信息
    company_data:{
      companyName:'',  // 公司名称
      companyType:'',  // 公司类型
      legalPerson:'',  // 法定代表人
      legalPersonType:'',  //  法人类型
      phoneNumber:'',   // 电话号码
      phoneNumber_note:'',   // 电话备注
      capital:'',       // 注册资本
      realCapital:'',   // 实收注册资金
      companyCode:'',  // 注册码
      creditNo:'',  // 企业信用代码
      orgCode:'',   // 组织机构代码
      businessScope:'',  // 经营范围
      authority:'',  // 登记机关
      companyStatus:'',   // 经营状态
      establishDate:'',  // 成立时间
      operationStartdate:'',  // 营业期限开始时间
      operationEnddate:'',  // 营业期限结束时间
      issueDate:'',  // 核准日期
      province:'',  // 省份
      provinceCode:'',   // 省份行政区号
      city:'',   // 地市
      cityCode:'',  // 地市行政区号
      district:'', // 地区
      districtCode:'',  // 地区行政区号
      companyAddress:'',  // 注册地址
      industry:'',  // 行业
      historyNames:'', // 曾用名
      lastUpdatedTime:'',  // 更新时间
      companyStatus:'',  // 登记状态
      email:'',   // 邮箱
      email_note:'',  // 邮箱备注
      address:'',  // 地址
      address_note:'',   // 地址备注
      website:'',  // 网址
      website_note:'', // 网址备注
    },
    


    // 银行信息
    opening_bank:'', // 开户行
    account:'', // 收款账户
    account_name:'', // 开户名称
  })
  const typeList = ref([
    {label:'园区企业',value:1},
    {label:'用户企业',value:2},
  ])
  const customerTypeList = ref([
    {label:'企业',value:1},
  ])
  const statusList= ref([
    {label:'正常',value:1},
    {label:'停用',value:2},
  ])
  const visible_Add = ref(false)
  const handleType = (e)=>{
    console.log(e)
    if(e == 1){
      customerTypeList.value = [
        {label:'企业',value:1},
      ]
      addItem.customer_type.value = 1
    }else{
      customerTypeList.value = [
        {label:'企业',value:1},
        {label:'个人',value:2},
      ]
      addItem.customer_type.value = 1
    }
  }
  const openAdd = () => {
    addItem.value = {
        type:1,
        customer_type:1,
        status:1,
        name:'',
        leader:'',
        phone:'',
        e_mail:'',
        card_id:'',
        file:'',
        tag_ids:[],
        remark:'',
        company_data:{
          companyName:'',  // 公司名称
          companyType:'',  // 公司类型
          legalPerson:'',  // 法定代表人
          legalPersonType:'',  //  法人类型
          phoneNumber:'',   // 电话号码
          phoneNumber_note:'',   // 电话备注
          capital:'',       // 注册资本
          realCapital:'',   // 实收注册资金
          companyCode:'',  // 注册码
          creditNo:'',  // 企业信用代码
          orgCode:'',   // 组织机构代码
          businessScope:'',  // 经营范围
          authority:'',  // 登记机关
          companyStatus:'',   // 经营状态
          establishDate:'',  // 成立时间
          operationStartdate:'',  // 营业期限开始时间
          operationEnddate:'',  // 营业期限结束时间
          issueDate:'',  // 核准日期
          province:'',  // 省份
          provinceCode:'',   // 省份行政区号
          city:'',   // 地市
          cityCode:'',  // 地市行政区号
          district:'', // 地区
          districtCode:'',  // 地区行政区号
          companyAddress:'',  // 注册地址
          industry:'',  // 行业
          historyNames:'', // 曾用名
          lastUpdatedTime:'',  // 更新时间
          companyStatus:'',  // 登记状态
          email:'',   // 邮箱
          email_note:'',  // 邮箱备注
          address:'',  // 地址
          address_note:'',   // 地址备注
          website:'',  // 网址
          website_note:'', // 网址备注
        },
        
        opening_bank:'', // 开户行
        account:'', // 收款账户
        account_name:'', // 开户名称
      }
      customerTypeList.value = [
        {label:'企业',value:1},
      ]
      visible_Add.value = true
  }
  
  const handleAddOk = async ()=>{
    let res = await dept.save(addItem.value)
    if(res.code == 200){
      Message.success('添加成功')
      setTimeout(function(){
          getList()
      },500)
      return true
    }else{
      Message.error(res.message)
      return false
    }
  }
  const handleSearch = (value) => {
        if (value) {
        loading.value = true;
        request({
            url:'system/dept/info',
            method: 'get',
            params:{
            keyword:value,
            pageNo:1,
            pageSize:1000,
            },
        }).then(res=>{
            console.log('公司信息：',res)
            deptSearchList.value = res.data.items
            loading.value = false;
        })
        } else {
        deptSearchList.value = []
        }
    };
    const handleYinhanInfo = (e)=>{
        console.log(e)
        deptSearchList.value.map((v,i)=>{
        if(v.creditNo == e){
            addItem.value.name = v.companyName
        }
        })
        request({
        url:'system/dept/getCompanyDetail',
        method: 'get',
        params:{
            keyword:e,
            
        },
        }).then(res=>{
        console.log('银行信息：',res)
        let _data = res.data
        addItem.value.company_data.companyType = _data.companyType
        addItem.value.company_data.legalPersonType = _data.legalPersonType
        addItem.value.company_data.phoneNumber = _data.contacts.phoneNumber[0].value || ''
        addItem.value.company_data.phoneNumber_note = _data.contacts.phoneNumber[0].note  || ''
        addItem.value.company_data.capital = _data.capital
        addItem.value.company_data.realCapital = _data.realCapital
        addItem.value.company_data.orgCode = _data.orgCode
        addItem.value.company_data.businessScope = _data.businessScope
        addItem.value.company_data.authority = _data.authority
        addItem.value.company_data.operationStartdate = _data.operationStartdate
        addItem.value.company_data.operationEnddate = _data.operationEnddate
        addItem.value.company_data.issueDate = _data.issueDate
        addItem.value.company_data.province = _data.province
        addItem.value.company_data.provinceCode = _data.provinceCode
        addItem.value.company_data.city = _data.city
        addItem.value.company_data.cityCode = _data.cityCode
        addItem.value.company_data.district = _data.district
        addItem.value.company_data.districtCode = _data.districtCode
        addItem.value.company_data.industry = _data.industry
        addItem.value.company_data.historyNames = _data.historyNames
        addItem.value.company_data.lastUpdatedTime = _data.lastUpdatedTime
        addItem.value.company_data.email = _data.contacts.email[0].value || ''
        addItem.value.company_data.email_note = _data.contacts.email[0].note  || ''
        addItem.value.company_data.address = _data.contacts.address[0].value  || ''
        addItem.value.company_data.address_note = _data.contacts.address[0].note || ''
        addItem.value.company_data.website = _data.contacts.website[0].value || ''
        addItem.value.company_data.website_note = _data.contacts.website[0].note || ''
        console.log(addItem.value)
        })
    }
onMounted(() => {
    getTagList()
    getList()
})
const tagList = ref([])
const getTagList = () => {
    request({
      url:'system/tag/index',
      method: 'get',
      params:{
        openPage:false
      },
    }).then(res=>{
      tagList.value = res.data.items
    })
}
const list = ref([])
const getList = ()=>{
        request({
            url: 'system/dept/index',
        }).then(res => {
          let arr = []
          res.data.map((v,i)=>{
            v.keywords = [
              v.name,
              pinyin(v.name,{toneType:'none',pattern:'first'}).split(' ').join(''),
              pinyin(v.name,{toneType:'none',pattern:'first'}).split(' ').join('').toUpperCase()
            ]
            if(v.status == 1){
                arr.push(v)
            }
          })
          console.log(res.data)
            list.value = arr
        })
    }

</script>
<style scoped>
    .contenBox{
      height:500px;
      padding:12px;
    }
    .contenBox::-webkit-scrollbar{
      display: none;
    }
    .marbot24{
      margin-bottom: 12px;
    }
</style>